// pages/main/main.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    width:0,
    height:0,
    dialogs:[{tname:'自定义弹窗1'},{tname:'自定义弹窗2'},{tname:'提示弹窗'},{tname:'模态窗'}],
    dialogList:[{name:'选项1'},{name:'选项2'}],
    dialog1:false,
    dialog2:false,
    dialog3:false,
    dialogContent:'这里是提示的内容'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      width:wx.getSystemInfoSync().windowWidth,
      height:wx.getSystemInfoSync().windowHeight
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  showDialog:function(e){
    var name=e.currentTarget.dataset.tname
    switch(name){
      case '自定义弹窗1':
        this.setData({dialog1:true})
        break;
      case '自定义弹窗2':
        this.setData({dialog2:true})
        break;
      case '提示弹窗':
        wx.showToast({
          title: this.data.dialogContent,
          icon:'success'
        })
        break;
      case '模态窗':
        this.setData({dialog3:true})
        break;
    }
  },
  itemChoose:function(e){
    let index=e.currentTarget.dataset.listindex
    console.log("选择了  "+this.data.dialogList[index].name)
    this.setData({dialog1:false})
  },
  btnConfirm:function(){
    console.log("点击了确定")
  },
  confirm:function(){
    console.log("点击了确定")
    this.setData({dialog3:false})
  }
})